#include "shader_manager.h"

namespace jlib {


Shader *ShaderManager::get (const std::string &name) noexcept {
  auto iter = this->_cache.find(name);
  if (iter == this->_cache.end())
    return nullptr;
  return iter->second;
}


Shader *ShaderManager::get (const std::string &name, const char *vs, const char *fs, const char *gs) noexcept {
  auto &ptr = this->_cache[name];
  if (!ptr && vs && fs)
    ptr = Object::create<Shader>(vs, fs, gs);
  return ptr;
}


void ShaderManager::clear () noexcept {
  this->_cache.clear();
}


} // namespace jlib